package service

import (
	"user/domain/model"
	"user/domain/repository"
)

type IUserService interface {
	GetOne(id int) (*model.User, error)
}

func NewUserService(userRepository repository.IUserRepository) IUserService {
	return &UserService{userRepository}
}

type UserService struct {
	UserRepository repository.IUserRepository
}

func (u *UserService) GetOne(id int) (user *model.User, err error) {
	if id == 0 {
		return
	}
	user, err = u.UserRepository.GetOneById(id)
	return
}
